package Help.Manager.Album;
import photos.core.commons.Contants;
import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;

import com.example.easynote.FullScreenImageActivity;
import com.example.easynote.R;
import com.tonicartos.widget.stickygridheaders.StickyGridHeadersGridView;



public class PhotosGroupedFragment extends Fragment implements OnItemClickListener{
	PhotosGroupedAdapter adapter;
	StickyGridHeadersGridView grid;
	
	public PhotosGroupedFragment() {
		
	}
	
	@Override
	public View onCreateView(
			LayoutInflater inflater, 
			ViewGroup container,
			Bundle savedInstanceState) {
		super.onCreateView(inflater, container, savedInstanceState);
		
		View layout = inflater.inflate(R.layout.fragment_photos_grouped, null);
		
		grid = (StickyGridHeadersGridView)layout.findViewById(R.id.groupedGrid);
		
		// Gá»�i Controller sáº¯p xáº¿p danh sÃ¡ch Photo.
		PhotosGroupedController controller = App.getPhotosGroupedController();
		controller.sort();
		
		this.adapter = new PhotosGroupedAdapter(
				getActivity(),
				controller.getPhotos());
		
		grid.setAdapter(this.adapter);
		
		grid.setOnItemClickListener(this);
	
		return layout;
	}

	
	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
		// TODO Auto-generated method stub
		Intent intent = new Intent(getActivity(), FullScreenImageActivity.class);

		intent.putExtra(Contants.Position, position);
		
		startActivity(intent);
	}
}
